export default {
  state: {
    name: 'zhangsan'
  },
  mutations: {
    updateName(state, payload) {
      state.name = payload;
    }
  },
  getters: {
    fullName(state) {
      return state.name + '1111';
    },
    fullNameExt(state, getters) {
      return getters.fullName + '2222';
    },
    fullNamePlus(state, getters, rootState) {
      return getters.fullNameExt + rootState.counter;
    }
  },
  actions: {
    updateNameAsyn(context, payload) {
      console.log(context);
      return new Promise((resolve, reject) => {
        setTimeout(() => {
          context.commit('updateName', payload.name);
          resolve(payload);
        }, 3000);
      });
    }
  }
};
